/*
//
//              INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license  agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in  accordance  with the terms of that agreement.
//    Copyright (c) 2007-2008 Intel Corporation. All Rights Reserved.
//
//
*/

#ifndef __UMC_AVS_MB_INFO_H
#define __UMC_AVS_MB_INFO_H

#include "ippdefs.h"
#include "ippvc.h"

#include "umc_avs_consts.h"

namespace UMC
{

// declare motion vector type
struct AVSMVector
{
    union
    {
        struct
        {
            Ipp16s x;
            Ipp16s y;
        } vector;
        Ipp32u scalar;
    };

    // cast operator
    inline
    operator IppiPoint (void)
    {
        IppiPoint point;

        point.x = vector.x;
        point.y = vector.y;

        return point;
    }
};

inline
AVSMVector operator + (AVSMVector &mvOne, AVSMVector &mvTwo)
{
    AVSMVector mvRes;

    mvRes.vector.x = (Ipp16s) (mvOne.vector.x + mvTwo.vector.x);
    mvRes.vector.y = (Ipp16s) (mvOne.vector.y + mvTwo.vector.y);

    return mvRes;
}

inline
AVSMVector operator - (AVSMVector &mvOne, AVSMVector &mvTwo)
{
    AVSMVector mvRes;

    mvRes.vector.x = (Ipp16s) (mvOne.vector.x - mvTwo.vector.x);
    mvRes.vector.y = (Ipp16s) (mvOne.vector.y - mvTwo.vector.y);

    return mvRes;
}


// declare structure to describe a macroblock
struct AVS_MB_INFO
{
    // we arranged this structure the special way,
    // to improve memory usage efficiency in deblocking.
    // This process reads only the first part of the structure.
    // Size of structure is 128 bytes.

    // macroblock parameters
    eAVSMbType MbType;                                          // (eAVSMbType) type of a macroblock
    Ipp32s QP;                                                  // (Ipp32s) QP of the macroblock
    AVSMVector mv[AVS_DIRECTIONS][4];                           // (AVSMVector [][]) motion vectors
    Ipp8u predType[4];                                          // (Ipp8u []) prediction types of each block
    Ipp8u refIdx[AVS_DIRECTIONS][4];                            // (Ipp8u []) reference indecies of each block

    Ipp16u MvNum;                                               // (Ipp16u) number of parts of a macroblock
    Ipp16u weighting_prediction;                                // (Ipp16u) weighting prediction flag
    Ipp32u MbCBP;                                               // (Ipp32u) a coded block pattern
    Ipp32s NumCoeffs[8];                                        // (Ipp32s []) array with coefficient numbers
    IppIntra8x8PredMode_H264 IntraLumaPredMode[4];              // (IppIntra8x8PredMode_H264 []) luminance prediction modes
    IppIntraChromaPredMode_H264 IntraChromaPredMode[4];         // (IppIntraChromaPredMode_H264 []) chrominance prediction modes

    eAVSDivBlockType divType;                                   // (eAVSDivBlockType) macroblock division type
};

} // namespace UMC

#endif // __UMC_AVS_MB_INFO_H
